# 方式1
f = open("./16_read_file.txt", "r")

# 这个会读取全部信息，如果文件超级大的话，会OOM
content = f.read()
print(content)
f.close() # 记得关闭文件流

print("-------------------------------")

# 方式2，with 方法会自动 close
with open("./16_read_file.txt", "r") as f1:
    print(f1.read())

print("-------------------------------")

# 方式3，使用死循环去一行一行读，防止大文件导致的OOM
with open("./16_read_file.txt", "r") as f2:
    while True:
        readline = f2.readline()
        if not readline:
            break
        print(readline)